@extends('layouts.layouts')
@section('title')
    <title>后台首页</title>
    <style>
        .file {
            position: relative;
            display: inline-block;
            background: #D0EEFF;
            border: 1px solid #99D3F5;
            border-radius: 4px;
            padding: 4px 12px;
            overflow: hidden;
            color: #1E88C7;
            text-decoration: none;
            text-indent: 0;
            line-height: 20px;
        }
        .file input {
            position: absolute;
            font-size: 100px;
            right: 0;
            top: 0;
            opacity: 0;
        }
        .file:hover {
            background: #AADFFD;
            border-color: #78C3F3;
            color: #004974;
            text-decoration: none;
        }
        .form-horizontal .form-group {
            margin-right: 5px;
            margin-left: -1px;
        }
    </style>
@endsection
@section('content')
    <style>

        .form-horizontal .form-group {
            margin-right: 5px;
            margin-left: -1px;
        }
    </style>
    <link rel="stylesheet" href="/lib/layer/theme/default/layer.css"/>
    <script type="text/javascript" src="/lib/layer/layer.js"></script>
    <link href="/css/ueditor.css" type="text/css" rel="stylesheet">
    <div class="content">
        <div class="header">
            <ul class="breadcrumb">
                <li><a href="/courseLearn/card">活动列表</a>／<a href="#">添加活动</a> </li>

            </ul>
        </div>
        <div class="main-content">
            <ul class="nav nav-tabs nav-tabs-course">
                <li role="presentation" class="course_add active"><a href="javascript:void(0);">课程推送</a></li>
            </ul>
            <form class="form-horizontal" id="courseFormInfo" action="" method="post">
                {{csrf_field()}}
                <div class="course_class row">
                    <div class="col-md-10">
                        <br>
                        <div class="tab-content">
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-3 control-label">体验活动名称</label>
                                <div class="col-sm-8">
                                    <input class="form-control" id="inputEmail3" name="name" placeholder="活动名称" type="text">
                                </div>
                            </div>
                            <div class="form-group" style="display:none;">
                                <label for="inputEmail3" class="col-sm-3 control-label">免费体验天数</label>
                                <div class="col-sm-8">
                                    <input class="form-control" id="inputEmail3" name="day" placeholder="体验天数" value="3" type="hidden">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputPassword3" class="col-sm-3 control-label">体验课程分类</label>
                                <div class="col-sm-8">
                                    <select class="form-control courseType" name="courseType" autocomplete="off">
                                        @foreach($types as $key => $type)
                                            <option value="{{$type->id}}">{{$type->title}}</option>
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                            <div class="form-group push_recommend">
                                <label for="inputPassword3" class="col-sm-3 control-label">活动时间</label>
                                <div class="col-sm-9">
                                    <div class="form-inline">
                                        <div class="form-group">
                                            <input type="text" class="form-control" class="startTime" name="start" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" placeholder="开始时间" value="">
                                        </div>&nbsp;至&nbsp;
                                        <div class="form-group">
                                            <input type="text" class="form-control" class="endTime" name="end" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"  placeholder="结束时间" value="">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <p>
                            <button type="button" class="btn btn-primary btn-lg col-md-offset-5" data-id="" onclick="cardCreate(this)" style="width:120px;background:#286090;color:#fff;">添加</button>
                        </p>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <script src="/js/course.js"></script>
    <script src="/lib/jquery.validate.js" type="text/javascript"></script>
    <script>
        function setRecommendPush(obj){
//            alert($(obj).val());
            var type = $(obj).val();
            if(type == 'RECOMMEND'){
                $('.push_recommend').css('display','block');
            }else{
                $('.push_recommend').css('display','none');
            }
        }
        function cardCreate(obj){
            var _token = '{{csrf_token()}}';
            var type = $('.courseType').val();
            var startTime = $("input[name='start']").val();
            var endTime = $("input[name='end']").val();
            var name = $("input[name='name']").val();
            var data = {_token:_token,name:name,type:type,start:startTime,end:endTime};

            $.ajax({
                url:'/course/card/postCreate',
                data:data,
                type:'POST',
                dataType:'json',
                success:function(res){
                    if(res.code == 0){
                        window.location.href='/courseLearn/card';
                    }
                }
            });
        }
    </script>
    <style type="text/css">
        .col-sm-2{
            width:60px;
        }
        .course_content{
            margin-right: -30px;
            margin-left: -30px;
            margin-top:5px;
        }
        .btn-success{
            background-image:none!important;
        }
    </style>
@endsection